package com.huanghuai.retail.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huanghuai.retail.entity.PBrandType;
import com.huanghuai.retail.mapper.BrandTypeMapper;
import com.huanghuai.retail.service.BrandTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class BrandTypeServiceImpl extends ServiceImpl<BrandTypeMapper, PBrandType> implements BrandTypeService {

    @Autowired
    private BrandTypeService brandTypeService;
    @Override
    public List<Long> findIds(List<Long> typeIds) {

        List<Long> ids = new ArrayList<>();
        LambdaQueryWrapper<PBrandType> queryWrapper = new LambdaQueryWrapper<>();
        if(typeIds!=null&&typeIds.size()==0){
            typeIds.add(-1L);
        }
        queryWrapper.in(typeIds!=null,PBrandType::getTypeId,typeIds);
        List<PBrandType> PBrandTypeList = brandTypeService.list(queryWrapper);

        for(int i = 0; i < PBrandTypeList.size(); i ++)
            ids.add(PBrandTypeList.get(i).getBrandId());
        return ids;
    }
}
